#ifndef WEB_API_H
#define WEB_API_H

#include "NodeClient.h"
#include <crow.h>
#include <crow/app.h>
#include <memory>
#include <thread>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/transport/TSocket.h>
#include <thrift/transport/TTransport.h>
#include <thrift/transport/TTransportUtils.h>
#include <vector>

class WebAPI {
private:
  std::thread workThread;
  crow::SimpleApp app;
  crow::websocket::connection *wsPreview = nullptr;
  std::shared_ptr<apache::thrift::transport::TTransport> transport;
  Thrift::NodeClientClient client;

public:
  WebAPI();
  ~WebAPI();
  void Boot(int port);
  void InputPreview(const std::vector<unsigned char> &jpegData);
};

#endif
